home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / server1.zip / _EXITRLS.QC < prev    next >
Text File  |  1996-08-31  |  5KB  |  162 lines

  1. /*
  2. **
  3. ** _exitrls.qc (ExitRules Code, 1.1)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. float EXITRULES_FRAGLIMIT = 40; // Players can exit only if at least one 
  26.                                 // player has at least this many frags.
  27.                                 // Must be >= 0
  28. float EXITRULES_TIMELIMIT = 1;  // Players can exit only if at least this many
  29.                                 // minutes passed on the current level.
  30.                                 // Must be >= 0.1
  31.  
  32. void(entity player) ExitRulesInfo =
  33. {
  34.    if (!USE_MODULE_EXITRULES) return;
  35.  
  36.                // 123456789#123456789#123456789#12345678
  37.    sprint(player,"# ExitRules: restricts exiting.\n");
  38.    sprint(player,"  Type 'help-exitrules' for help.\n");
  39. };
  40.  
  41. void(entity player) ExitRulesInit =
  42. {
  43.    if (!USE_MODULE_EXITRULES) return;
  44.  
  45.    stuffcmd(player,"alias help-exitrules \"impulse 210\";\n");
  46. };
  47.  
  48. void(entity player) ExitRulesHelp =
  49. {
  50.    if (!USE_MODULE_EXITRULES) return;
  51.  
  52.                // 123456789#123456789#123456789#12345678
  53.    sprint(player,"# ExitRules: imposes restrictions on\n");
  54.    sprint(player,"  exiting a level. Current rules are:\n");
  55.    sprint(player,"  ");
  56.    ExitRulesLevelInfo(player);
  57.    if (USE_MODULE_VOTE && USE_SUBMODULE_VOTE_EXITRULES) { //#jp#(Vote)
  58.       //             123456789#123456789#123456789#12345678
  59.       sprint(player,"  ExitRules may be disabled by voting\n");
  60.       sprint(player,"  via the command 'vote-exitrules'.\n");
  61.    }
  62. };
  63.  
  64. void(entity player) ExitRulesLevelInfo =
  65. {
  66.    if (!USE_MODULE_EXITRULES) return;
  67.  
  68.    if (exitrules_status == EXITRULES_STATUS_TIGHT) {
  69.       local string tmpstr;
  70.                   // 123456789#123456789#123456789#12345678
  71.       sprint(player,"ExitRules: before you can exit one\n");
  72.       sprint(player,"player must have ");
  73.       tmpstr = ftos(exitrules_fraglimit);
  74.       sprint(player,tmpstr);
  75.       sprint(player," frags.\n");
  76.    } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  77.       sprint(player,"ExitRules: you can exit.\n");
  78.    }
  79. };
  80.  
  81. void() ExitRulesSetValues =
  82. {
  83.    if (!USE_MODULE_EXITRULES) return;
  84.  
  85.    if (!exitrules_inited) {
  86.       // exitrules are not sensible if 'noexit' is active
  87.       if (cvar("noexit")) {
  88.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  89.       // disable exitrules for start level and levels with no exit 
  90.       } else if   (world.model == "maps/start.bsp") {
  91.          exitrules_status    = EXITRULES_STATUS_SOFT;
  92.       } else if (world.model == "maps/end.bsp") {
  93.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  94.       } else if (world.model == "maps/dm1.bsp") {
  95.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  96.       } else if (world.model == "maps/dm2.bsp") {
  97.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  98.       } else if (world.model == "maps/dm3.bsp") {
  99.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  100.       } else if (world.model == "maps/dm4.bsp") {
  101.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  102.       } else if (world.model == "maps/dm5.bsp") {
  103.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  104.       } else if (world.model == "maps/dm6.bsp") {
  105.          exitrules_status    = EXITRULES_STATUS_DISABLED;
  106.       } else {
  107.          exitrules_status    = EXITRULES_STATUS_TIGHT;
  108.          exitrules_fraglimit = EXITRULES_FRAGLIMIT;
  109.          exitrules_timelimit = EXITRULES_TIMELIMIT;
  110.       }
  111.       exitrules_inited = 1;
  112.    }
  113. };
  114.  
  115. float(entity player) ExitRulesExitingIsNotAllowed =
  116. {
  117.    if (!USE_MODULE_EXITRULES) return(0);
  118.  
  119.    player.exitrules_death = 2;
  120.    if (exitrules_status == EXITRULES_STATUS_DISABLED) {
  121.       player.exitrules_death = 0;
  122.    } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  123.       player.exitrules_death = 0;
  124.    } else {
  125.       local entity e;
  126.       e = find(world, classname, "player");
  127.       while (e) {
  128.          if (e.frags >= exitrules_fraglimit) {
  129.             if (e.deadflag != DEAD_DEAD) {
  130.                player.exitrules_death = 0;
  131.             }
  132.          }
  133.          e = find(e, classname, "player");
  134.       }
  135.    } 
  136.    if (!player.exitrules_death) {
  137.       if (time < exitrules_timelimit*60) {
  138.          player.exitrules_death = 1;
  139.       }
  140.    }
  141.    return(player.exitrules_death);
  142. };
  143.  
  144. void(entity player) ExitRulesClientObituary =
  145. {
  146.    if (player.exitrules_death == 1) {
  147.       bprint (player.netname);
  148.       bprint(" tried to exit before ");
  149.       bprint(ftos(exitrules_timelimit));
  150.       bprint(" minutes had passed on this level.\n");
  151.    } else {
  152.       bprint (player.netname);
  153.       bprint(" tried to exit before a player had reached ");
  154.       bprint(ftos(exitrules_fraglimit));
  155.       bprint(" frags.\n");
  156.    }
  157.    player.exitrules_death = 0;
  158. };
  159.  
  160.  
  161.  
  162.